package com.mail.server.controller;


import com.mail.model.db.SmsHomeAdvertise;
import com.mail.server.common.R;
import com.mail.server.service.SmsHomeAdvertiseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.ws.rs.QueryParam;
import java.util.List;

/**
 * <p>
 * 首页轮播广告表 前端控制器
 * </p>
 *
 * @author WJZ
 * @since 2022-06-20
 */
@RestController
@RequestMapping("/home/advertise/")
public class SmsHomeAdvertiseController {
    @Autowired
    private SmsHomeAdvertiseService service;

    @PostMapping("create")
    public R create(@RequestBody SmsHomeAdvertise advertise) {
        return service.create(advertise);
    }

    @PostMapping("delete")
    public R delete(@RequestParam("ids") List<Long> ids) {
        return service.delete(ids);
    }

    @GetMapping("list")
    public R list(@RequestParam(value = "endTime", required = false) String endTime,
                  @RequestParam(value = "name", required = false) String name,
                  @RequestParam(value = "pageNum", required = false) Long pageNum,
                  @RequestParam(value = "pageSize", required = false) Long pageSize,
                  @RequestParam(value = "type", required = false) Integer type) {
        return service.list(endTime, name, pageNum, pageSize, type);
    }
    @PostMapping("update/status/{id}")
    public R updateStatus(@PathVariable Long id,@RequestParam("status")Integer status){
        return service.updateStatus(id,status);
    }
    @PostMapping("/update/{id}")
    public R updateById(@PathVariable Long id,@RequestBody SmsHomeAdvertise advertise){
        return service.updateById(id,advertise);
    }
    @GetMapping("{id}")
    public R getAdvertiseById(@PathVariable Long id){
        return service.getAdvertiseById(id);
    }
}
